package com.sskj.gcc.ui.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.sskj.common.adapter.MyFragmentPagerAdapter;
import com.sskj.common.util.ToastUtil;
import com.sskj.gcc.R;
import com.sskj.gcc.presenter.PayInPresenter;
import com.sskj.lib.RConfig;
import com.sskj.lib.base.BaseActivity;

import java.util.ArrayList;

import butterknife.BindView;

@Route(path = RConfig.APP_PAY_IN)
public class PayInActivity extends BaseActivity<PayInPresenter> {

    @BindView(R.id.rg_pay_in)
    RadioGroup payInRg;
    @BindView(R.id.vp_pay_in)
    ViewPager payInVp;
    @BindView(R.id.rb_pay_in_left)
    RadioButton rbPayInLeft;
    @BindView(R.id.rb_pay_in_right)
    RadioButton rbPayInRight;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_pay_in;
    }

    @Override
    public PayInPresenter getPresenter() {
        return new PayInPresenter();
    }

    @Override
    protected void initView() {
        payInRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.rb_pay_in_left) {
                    payInVp.setCurrentItem(0);

                } else {
                    payInVp.setCurrentItem(1);
                }
            }
        });

        ArrayList<Fragment> fragments = new ArrayList<>();
        fragments.add((Fragment) ARouter.getInstance().build(RConfig.APP_FRAGMENT_PAY_IN1).navigation());
        fragments.add((Fragment) ARouter.getInstance().build(RConfig.APP_FRAGMENT_PAY_IN).navigation());

        payInVp.setAdapter(new MyFragmentPagerAdapter(getSupportFragmentManager(), fragments));
        payInVp.setCurrentItem(1);
    }
}
